import { movieList } from '@/network/film'
import { mapState } from 'vuex'
const filmMixin = {
  created() {
    this.getMovieList()
  },
  methods: {
    async getMovieList() {
      const { data: res } = await movieList(this.num, this.type, this.cities.cityId)
      this.dataList.push(...res.films)
    }
  },
  mounted() {
    this.$bus.$on('pullingUp', () => {
      ++this.num
      this.getMovieList()
    })
  },
  deactivated() {
    this.$bus.$off('pullingUp')
  },
  computed: {
    ...mapState('cities', ['cities'])
  }
}

export { filmMixin }
